<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@page import="java.util.*" import="cameraConfig.*" import="user.*" import="utils.*" import="cameraConfig.*" import="java.net.URI;"%>
<%@page language="java" contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<c:if test="${!user.isLoggedIn() || user.isInactive() || !user.isAdmin()}">
	<c:redirect url="error.jsp"/>
</c:if>
<head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/Resources/bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/Resources/Styles/back.css">
    <script src="${pageContext.request.contextPath}/Resources/Scripts/jquery.min.js"></script>
    <script src="${pageContext.request.contextPath}/Resources/Scripts/script.js"></script>
    <script src="${pageContext.request.contextPath}/Resources/bootstrap/js/bootstrap.min.js" type="text/javascript"></script>
</head>
<body>
	<c:if test="${!empty errorMessage}">
		<strong>Oooops... folgender Fehler ist aufgetreten:</strong>			
		<p>${errorMessage}</p>
		<p>Bitte loggen Sie sich ein!</p>
		<a href="login.html">Zur Login Seite wechseln</a>
	</c:if>
	<c:if test="${empty errorMessage}">
	    <form action="EditUserController" name="appform" method="post" id="target" class="form-horizontal">
	        <div class="item-active">
	            <div class="container">
	                <div class="panel active">
	                    <ul class="nav nav-tabs nav-pills" id="myTab">
	                        <li class=""> <a class="cameraFilter" href="#cameraFilter" data-toggle="tab">Cameras</a>
	                        <li class="active dropdown">
	                            <a class="dropdown-toggle" data-toggle="dropdown">Management<span class="caret"></span></a>
	                            <ul class="dropdown-menu" role="menu">
	                                <li><a class="addUser" href="#addUser" data-toggle="tab">Add New user</a></li>
	                                <li><a class="showUsers" href="#ShowUsers" data-toggle="tab">Show User List</a></li>
	                                <li><a class="editCameras" href="#EditCameras" data-toggle="tab">Camera Management</a></li>
	                            </ul>
	                        </li>
	                        <li class=""> <a href="#" data-toggle="tab">About</a>
	                        <li class="pull-right"> <a class="logout" href="#" data-toggle="tab">Logout</a>
	                    </ul>
	                    <br>
	                    <div class="tab-content">
	                        <c:if test="${UserBean.isAdmin()}">
	                            <div class="row">
	                                <fieldset>
	                                    <div class="form-group">
	                                        <label for="loginname" class="col-lg-3 control-label">Loginname:</label>
	                                        <div class="col-md-6">
	                                            <input type="text" required="" class="form-control input-md" placeholder="Loginname" name="username" value="<%= request.getAttribute("UsernameToEdit") %>" id="loginname">
	                                            <span class="help-block">Enter loginname here</span>
	                                        </div>
	                                    </div>
	                                    <div class="component" data-content="&lt;form role=&quot;form&quot;&gt;" data-title="Text Input" data-trigger="manual" data-html="true">
	                                        <!-- Text input-->
	                                        <div class="form-group">
	                                            <label for="username" class="col-lg-3 control-label">Username:</label>
	                                            <div class="col-md-6">
	                                                <input type="text" required="" class="form-control input-md" placeholder="Username" name="fullname" value="<%= request.getAttribute("FullnameToEdit") %>" id="username">
	                                                <span class="help-block">Enter username here</span>
	                                            </div>
	                                        </div>
	                                    </div>
	                                    <div class="component" data-content="&lt;form role=&quot;form&quot;&gt;" data-title="Text Input" data-trigger="manual" data-html="true">
	                                        <!-- Text input-->
	                                        <div class="form-group">
	                                            <label for="location" class="col-lg-3 control-label">Location:</label>
	                                            <div class="col-md-6">
													<select class="form-control" name="location" id="location">
														<c:forEach items="${locations}" var="location">
															<option value="${location.getName()}"<c:if test="${location.getName() == LocationToEdit}"> selected</c:if>>${location.getName()}</option>
														</c:forEach>
													</select>
													<span class="help-block">Choose location here</span>
												</div>
	                                        </div>
	                                    </div>
	                                    <div class="component" data-content="&lt;form role=&quot;form&quot;&gt;" data-title="Password Input" data-trigger="manual" data-html="true">
		                                    <!-- Password input-->
		                                    <div class="form-group">
		                                        <label for="password" class="col-lg-3 control-label">Password:</label>
		                                        <div class="col-md-6">
		                                            <input type="password" class="form-control input-md" placeholder="Password" name="password" id="password">
		                                            <span class="help-block">Enter user password here</span>
		                                        </div>
		                                    </div>
		                                </div>
		                                <div class="component" data-content="&lt;form role=&quot;form&quot;&gt;" data-title="Password Input" data-trigger="manual" data-html="true">
		                                    <!-- Password input-->
		                                    <div class="form-group">
		                                        <label for="confPassword" class="col-lg-3 control-label">Confirm password:</label>
		                                        <div class="col-md-6">
		                                            <input type="password" class="form-control input-md" placeholder="Confirm password" name="confPassword" id="confPassword">
		                                            <span class="help-block">Confirm password here</span>
		                                        </div>
		                                    </div>
		                                </div>
	                                    <div class="component" data-content="&lt;form role=&quot;form&quot;&gt;" data-title="Select Basic" data-trigger="manual" data-html="true">
	                                        <!-- Select Basic -->
	                                        <div class="form-group">
	                                            <label for="userGroup" class="col-lg-3 control-label">User group:</label>
	                                            <div class="col-md-6">
	                                                <select class="form-control" name="admin" id="userGroup">
	                                                    <option value="1" <c:if test="<%= request.getAttribute(\"IsAdminToEdit\").equals(\"true\") %>"> selected="selected"</c:if> >Admin</option>
	                                                    <option value="0" <c:if test="<%= request.getAttribute(\"IsAdminToEdit\").equals(\"false\") %>"> selected="selected"</c:if> >User</option>
	                                                </select>
	                                            </div>
	                                        </div>
	                                    </div>
	                                    <div class="component" data-content="&lt;form role=&quot;form&quot;&gt;" data-title="Select Basic" data-trigger="manual" data-html="true">
	                                        <!-- Select Basic -->
	                                        <div class="form-group">
	                                            <label for="active" class="col-lg-3 control-label">Inactive:</label>
	                                            <div class="col-md-6">
	                                                <select class="form-control" name="inactive" id="inactive">
	                                                    <option value="1" <c:if test="<%= request.getAttribute(\"IsInactiveToEdit\").equals(\"true\") %>"> selected="selected"</c:if> >Yes</option>
	                                                    <option value="0" <c:if test="<%= request.getAttribute(\"IsInactiveToEdit\").equals(\"false\") %>"> selected="selected"</c:if> >No</option> 
	                                                </select>
	                                            </div>
	                                        </div>
	                                    </div>
	                                    <div class="component" data-content="&lt;form role=&quot;form&quot;&gt;" data-title="Button" data-trigger="manual" data-html="true">
	                                        <div class="form-group">
	                                            <div class="col-md-6">
	                                                <label for="brnOk" class="col-lg-3 control-label"></label>
	                                                <button name="btnSaveChance" value="<%= request.getAttribute("UsernameToEdit") %>" type="submit" class="btn btn-primary" style="width: 8em">OK</button>
	                                            </div>
	                                        </div>
	                                    </div>
	                                </fieldset>
	                            </div>
	                        </c:if>
	                    </div>
	                </div>
	            </div>
	        </div>
	    </form>
	</c:if>
</body>
</html>
